/*
 * Copyright (c) 2022  by Junzhao
 * THIS FILE IS PART OF JAVASE Song Huongkang PROJECT
 * All Rights Reserved.
 */

package 练习.static应用;

public class CircleTest {

    public static void main(String[] args) {
        System.out.println(Circle.getInit() + " " + Circle.getTotal());
        Circle c1 = new Circle();
        System.out.println(Circle.getInit() + " " + Circle.getTotal());
        Circle c2 = new Circle();
        System.out.println(Circle.getInit() + " " + Circle.getTotal());
        Circle c3 = new Circle(10.0);
        System.out.println(Circle.getInit() + " " + Circle.getTotal());


        System.out.println(c1.getId() + " " + c2.getId()+ " " + c3.getId());
        c1.setRadius(3.1);
        c2.setRadius(2.0);
        System.out.println(c1.findArea() + " " + c2.findArea()+ " " + c3.findArea());

    }
}
class Circle{
    private double radius;
    private int id;

    private static int total;// 创建的个数
    private static int init = 1001;// 被所有的共享

    public double findArea(){
        return Math.PI * radius * radius;
    }

    public static int getTotal() {
        return total;
    }

    public static int getInit() {
        return init;
    }


    public Circle(double radius){
        this();
        this.radius = radius;
//        this.id = init++;
//        total++;
    }

    public Circle() {
        this.id = init++;// 先赋值 再加一
        total++;
    }




    public double getRadius() {
        return radius;
    }

    public void setRadius(double radius) {
        this.radius = radius;
    }

    public int getId() {
        return id;
    }
}
